home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Apple Development Tools / MacsBug 6.5.4a6.sit / MacsBug 6.5.4a6 / Building dcmds / dcmd Includes / Dcmd.p < prev    next >
Text File  |  1998-09-22  |  9KB  |  259 lines

  1. {
  2.      File:        dcmd.p
  3.  
  4.      Contains:    MacsBug debugger command interface.
  5.  
  6.      Version:    Technology:    MacsBug
  7.  
  8.                  Release:    6.5.3
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.  
  12.                  All rights reserved.
  13.  
  14.      Bugs?:        If you find a problem with this file, send the file and version
  15.                  information (from above) and the problem description to:
  16.  
  17.                      Internet:    apple.bugs@applelink.apple.com
  18.                      AppleLink:    APPLE.BUGS
  19.  
  20. }
  21. {$IFC UNDEFINED UsingIncludes}
  22. {$SETC UsingIncludes := 0}
  23. {$ENDC}
  24.  
  25. {$IFC NOT UsingIncludes}
  26.  UNIT dcmd;
  27.  INTERFACE
  28. {$ENDC}
  29.  
  30. {$IFC UNDEFINED __DCMD__}
  31. {$SETC __DCMD__ := 1}
  32.  
  33. {$I+}
  34. {$SETC dcmdIncludes := UsingIncludes}
  35. {$SETC UsingIncludes := 1}
  36.  
  37. {$IFC UNDEFINED __MACTYPES__}
  38. {$I MacTypes.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  41. {$I MachineExceptions.p}
  42. {$ENDC}
  43.  
  44. {$PUSH}
  45. {$ALIGN MAC68K}
  46. {$LibExport+}
  47.  
  48. {  Possible requests from the debugger to the command }
  49.  
  50. CONST
  51.     dcmdInit                    = 0;                            {  Initialize the Dcmd  }
  52.     dcmdDoIt                    = 1;                            {  Normal Dcmd execution  }
  53.     dcmdHelp                    = 2;                            {  Display help for Dcmd  }
  54.                                                                 {  Requests added to MacsBug in 6.5d10 that are only sent to format 3 or newer dcmds.  }
  55.     dcmdSecondaryInit            = 3;                            {  Second time to init after all System patches have been loaded  }
  56.     dcmdShutdown                = 4;                            {  Dcmd should remove any patches (if possible)  }
  57.     dcmdGetInfo                    = 5;                            {  Return dcmd version and pointer to help text  }
  58. {  68K register file indices into the RegisterFile. }
  59.     D0Register                    = 0;
  60.     D1Register                    = 1;
  61.     D2Register                    = 2;
  62.     D3Register                    = 3;
  63.     D4Register                    = 4;
  64.     D5Register                    = 5;
  65.     D6Register                    = 6;
  66.     D7Register                    = 7;
  67.     A0Register                    = 8;
  68.     A1Register                    = 9;
  69.     A2Register                    = 10;
  70.     A3Register                    = 11;
  71.     A4Register                    = 12;
  72.     A5Register                    = 13;
  73.     A6Register                    = 14;
  74.     A7Register                    = 15;
  75.     PCRegister                    = 16;
  76.     SRRegister                    = 17;                            {  SR is only 16 bits and is stored in the high word  }
  77. {  Heap block types }
  78.     freeBlock                    = 0;
  79.     nonrelocatableBlock            = 1;
  80.     relocatableBlock            = 2;
  81. {  The format of the 68K registers passed to the dcmd. }
  82.  
  83. TYPE
  84.     RegisterFile = ARRAY [0..17] OF UInt32;
  85.  
  86.     RegisterFilePtr = ^RegisterFile;
  87.  
  88. {  Structure used to pass information to and from the dcmd. }
  89.     dcmdBlock = PACKED RECORD
  90.         registerFile:                RegisterFilePtr;                    { pointer to 68K CPU register set }
  91.         request:                    INTEGER;                            { what action we are requested to take }
  92.         aborted:                    BOOLEAN;                            { Set to true if the user types a key while scrolling }
  93.         pad1:                        BOOLEAN;                            { align to word boundary }
  94.         macsBugVersion:                UInt32;                                { version of MacsBug we are running under }
  95.         maxCallback:                UInt16;                                { maximum valid callback we can make }
  96.         currentISA:                    UInt8;                                { ISA of current PC }
  97.         pad2:                        UInt8;                                { align to word boundary }
  98.         theException:                ^ExceptionInformationPowerPC;        { Pointer to PowerPC machine state if ISA is PowerPC }
  99.         requestIOBlock:                Ptr;                                { general-purpose input/output data block pointer }
  100.     END;
  101.     dcmdBlockPtr = ^dcmdBlock;
  102.  
  103.     GetInfoRequestBlock = RECORD
  104.         usageStr:                    Str255;
  105.         creditsStr:                    Str255;
  106.         dcmdVersion:                NumVersion;
  107.     END;
  108.     GetInfoRequestBlockPtr = ^GetInfoRequestBlock;
  109.  
  110. {
  111.     MacsBug callback routines that can be called by the dcmd.
  112. }
  113.  
  114. {
  115.     Draw the text in the Pascal string as one or more lines separated by CR's.
  116.     Each line causes the MacsBug display to be scrolled and the new line to be
  117.     drawn at the bottom. If the user types a key while scrolling then the aborted
  118.     flag is set telling the command to terminate immediately.
  119. }
  120. PROCEDURE dcmdDrawLine(str: ConstStr255Param);
  121.  
  122. {
  123.     Draw the text in the Pascal string as a continuation of the current line.
  124.     CR's are not given special treatment.
  125. }
  126. PROCEDURE dcmdDrawString(str: ConstStr255Param);
  127.  
  128. {
  129.     Draw a given number of characters starting from the given pointer as a 
  130.     continuation of the current line. CR's are not given special treatment.
  131. }
  132. PROCEDURE dcmdDrawText(text: StringPtr; length: INTEGER);
  133.  
  134. {
  135.     Scrolls the MacsBug display up one line leaving a blank line at the bottom.
  136. }
  137. PROCEDURE dcmdScroll;
  138.  
  139. {
  140.     Display the Pascal string in the command line area and wait for a key to be pressed.
  141.     Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  142.     key and adds it to the command line once the current command completes. Typing any
  143.     key other than Return sets the aborted flag and tells the command to terminate immediately.
  144. }
  145. FUNCTION dcmdDrawPrompt(str: ConstStr255Param): BOOLEAN;
  146.  
  147. {
  148.     Get the current command line position.
  149. }
  150. FUNCTION dcmdGetPosition: INTEGER;
  151.  
  152. {
  153.     Set the current command line position. This should only be set to a value returned 
  154.     by dcmdGetPosition.
  155. }
  156. PROCEDURE dcmdSetPosition(pos: INTEGER);
  157.  
  158. {
  159.     Return the next character on the command line or CR if the entire line has been scanned
  160. }
  161. FUNCTION dcmdGetNextChar: INTEGER;
  162.  
  163. {
  164.     Return the next character on the command line or CR if the entire line has been scanned.
  165.     However, the current command line position is not changed.
  166. }
  167. FUNCTION dcmdPeekAtNextChar: INTEGER;
  168.  
  169. {
  170.     Copy all characters from the command line to the parameter string until a delimiter
  171.     is found or the end of the command line is reached. A delimiter is either a space,
  172.     a comma or a CR. Both single and double quoted strings are allowed on the command
  173.     line. However, the leading and trailing quotes must be of the same type. The parameter
  174.     string is returned without the quotes. This function returns the delimiter.
  175. }
  176. FUNCTION dcmdGetNextParameter(str: Str255): INTEGER;
  177.  
  178. {
  179.     Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  180.     This function returns the delimiter after the expression. The possible delimiters are
  181.     space, comma and CR. Space is not treated as a delimiter in the middle of expressions,
  182.     unless it's before a binary '-' (minus). For instance, '1 + 2' will return a value of 3
  183.     and the delimiter will be the char following the 2. '1 - 2' will return a value of 1
  184.     and the delimeter is the space character before the '-'. This is done so that built-in
  185.     commands and dcmds can properly parse '-x' options. The return parameter 'ok' tells if
  186.     the expression was parsed successfully as far as syntax is concerned.
  187. }
  188. FUNCTION dcmdGetNextExpression(VAR value: LONGINT; VAR ok: BOOLEAN): INTEGER;
  189.  
  190. {
  191.     Copy the break message MacsBug displayed the last time it was entered into str.
  192.     This may contain multiple lines separated by CR's.
  193. }
  194. PROCEDURE dcmdGetBreakMessage(str: Str255);
  195.  
  196. {
  197.     Return a symbolic representation for address in str. If no symbol can be found
  198.     then an empty string is returned. The format of the symbol returned is Name+00000.
  199. }
  200. PROCEDURE dcmdGetNameAndOffset(address: LONGINT; str: Str255);
  201.  
  202. {
  203.     Return the trap name for the trap number. If no symbol can be found
  204.     then an empty string is returned.
  205. }
  206. PROCEDURE dcmdGetTrapName(trapNumber: INTEGER; trapName: Str255);
  207.  
  208. {
  209.     Return a pointer the macro name for the given value. If no macro can be found
  210.     then a nil is returned.
  211. }
  212. FUNCTION dcmdGetMacroName(value: LONGINT): StringPtr;
  213.  
  214. {
  215.     When a debugger command is called, the debugger's world (low memory) is installed.
  216.     Commands that want to reference the user's world can swap back and forth between the
  217.     two worlds by making this call. This procedure does nothing in MacsBug; there is no
  218.     distinction between user and debugger worlds. It is included to support other
  219.     debuggers that might want to take advantage of it.
  220. }
  221. PROCEDURE dcmdSwapWorlds;
  222.  
  223. {
  224.     Toggle between the user and debugger displays. The first call restores the user's actual screen.
  225.     The second call restores the debugger's screen.
  226. }
  227. PROCEDURE dcmdSwapScreens;
  228.  
  229. {
  230.     Walk through the blocks in the current heap, calling DoThis for each block. DoThis should
  231.     be a procedure of the form:
  232.                 
  233.         pascal void DoThis (long blockAddress, long blockLength, long addrOfMasterPtr,
  234.                              short blockType, Boolean locked, Boolean purgeable, Boolean resource)
  235.  
  236.     The blockAddress and blockLength pertain to the data in the heap block, not including
  237.     the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  238.     not the value of the master ptr. The blockType is defined by the constants freeBlock,
  239.     nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  240.     reflect the state of the block.
  241. }
  242.  
  243.  
  244. TYPE
  245.     DoThisPtr = ProcPtr;  { PROCEDURE DoThisPtr(blockAddress: LONGINT; blockLength: LONGINT; addrOfMasterPtr: LONGINT; blockType: INTEGER; locked: BOOLEAN; purgeable: BOOLEAN; resource: BOOLEAN); }
  246.  
  247.  
  248. PROCEDURE dcmdForAllHeapBlocks(DoThis: DoThisPtr);
  249. {$ALIGN RESET}
  250. {$POP}
  251.  
  252. {$SETC UsingIncludes := dcmdIncludes}
  253.  
  254. {$ENDC} {__DCMD__}
  255.  
  256. {$IFC NOT UsingIncludes}
  257.  END.
  258. {$ENDC}
  259.